home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / lisp / ilisp / ild.mail / text0000.txt < prev   
Encoding:
Text File  |  1995-01-26  |  15.3 KB  |  425 lines

  1. I think it is great that you are willing to maintain ILisp. ILisp is the most
  2. viable Lisp development environment available. I use it many hours a day.
  3.  
  4. I'd like to contribute an addition to ILisp. I wrote a package that uses a
  5. standard set of single-keystroke bindings to interface with a variety of
  6. different debuggers. It is vaguely modelled after the Symbolics debugger. It
  7. provides two key advantages: single keystrokes for moving up and down the
  8. stack, and a uniform interface to different debuggers. I find that useful
  9. since I often work simultaneously with different Lisps and can never remember
  10. the particulars of each one's debugger.
  11.  
  12. Anyway, I think that it would be of great use to others. It shouldn't take you
  13. very long to `officially' integrate it with ILisp. It basically works already
  14. with Lucid, Allegro, CMUCL, and AKCL and is fairly reliable. I've used it for
  15. years already. Not all debugger commands are available in all implementations.
  16. Some are but I didn't know how to get them to work. These are noted in the
  17. code. If you know how to fix them that would be great.
  18.  
  19. I also have written an improved debugger for use with Scheme->C along with an
  20. interface between that debugger and ILD. There are still some problems that I
  21. have to iron out though before I release that code.
  22.  
  23. I hereby give you permission to distribute this code to anyone subject to the
  24. restrictions that it is available on an as is basis with no guarantee of its
  25. correctness of suitability for any purpose, that I am not held liable for
  26. damages resulting from its use, and that I be given credit by name for this
  27. contribution.
  28.     Jeff (home page http://www.cdf.toronto.edu:/DCS/Personal/Siskind.html)
  29. -------------------------------------------------------------------------------
  30. ;;; ILD: A common Common Lisp debugger user interface for ILisp.
  31. ;;;   ---Jeffrey Mark Siskind
  32.  
  33. ;;; Keystroke c-u? What it does
  34. ;;; ---------------------------------------------------------
  35. ;;; m-a            Abort
  36. ;;; m-c            Continue
  37. ;;; c-m-n     *    Next stack frame
  38. ;;; c-m-p     *    Previous stack frame
  39. ;;; c-c <          Top stack frame
  40. ;;; c-c >          Bottom stack frame
  41. ;;; m-b            Backtrace
  42. ;;; c-m-d          Display all locals
  43. ;;; c-m-l     *    Display particular local
  44. ;;; c-c r          Return
  45. ;;; c-m-r          Retry
  46. ;;; c-x t          Trap on exit
  47. ;;; c-c L          Select Lisp interaction buffer
  48. ;;; c-z c-s        Sets compiler options for maximally debuggablity
  49. ;;; c-z c-f        Sets compiler options for fastest but least debuggable code
  50.  
  51. (require 'ilisp)
  52.  
  53. (deflocal ild-abort-string nil)
  54. (deflocal ild-continue-string nil)
  55. (deflocal ild-next-string nil)
  56. (deflocal ild-next-string-arg nil)
  57. (deflocal ild-previous-string nil)
  58. (deflocal ild-previous-string-arg nil)
  59. (deflocal ild-top-string nil)
  60. (deflocal ild-bottom-string nil)
  61. (deflocal ild-backtrace-string nil)
  62. (deflocal ild-locals-string nil)
  63. (deflocal ild-local-string-arg nil)
  64. (deflocal ild-return-string nil)
  65. (deflocal ild-retry-string nil)
  66. (deflocal ild-trap-on-exit-string nil)
  67.  
  68. (defun ild-debugger-command (string)
  69.  (process-send-string (get-buffer-process (current-buffer))
  70.               (format "%s\n" string)))
  71.  
  72. (defun ild-prompt ()
  73.  (save-excursion
  74.   (beginning-of-line)
  75.   (comint-skip-prompt)
  76.   (eobp)))
  77.  
  78. (defun ild-abort ()
  79.  (interactive)
  80.  (if ild-abort-string
  81.      (ild-debugger-command ild-abort-string)
  82.      (beep)))
  83.  
  84. (defun ild-continue (&optional arg)
  85.  (interactive "P")
  86.  (if (ild-prompt)
  87.      (if ild-continue-string
  88.      (ild-debugger-command ild-continue-string)
  89.      (beep))
  90.      (if arg (capitalize-word arg) (capitalize-word 1))))
  91.  
  92. (defun ild-next (&optional arg)
  93.  (interactive "P")
  94.  (if arg
  95.      (if ild-next-string-arg
  96.      (ild-debugger-command (format ild-next-string-arg arg))
  97.      (beep))
  98.      (if ild-next-string
  99.      (ild-debugger-command ild-next-string)
  100.      (beep))))
  101.  
  102. (defun ild-previous (&optional arg)
  103.  (interactive "P")
  104.  (if arg
  105.      (if ild-previous-string-arg
  106.      (ild-debugger-command (format ild-previous-string-arg arg))
  107.      (beep))
  108.      (if ild-previous-string
  109.      (ild-debugger-command ild-previous-string)
  110.      (beep))))
  111.  
  112. (defun ild-top (&optional arg)
  113.  (interactive "P")
  114.  (if ild-top-string
  115.      (ild-debugger-command ild-top-string)
  116.      (beep)))
  117.  
  118. (defun ild-bottom (&optional arg)
  119.  (interactive "P")
  120.  (if ild-bottom-string
  121.      (ild-debugger-command ild-bottom-string)
  122.      (beep)))
  123.  
  124. (defun ild-backtrace (&optional arg)
  125.  (interactive "P")
  126.  (if (ild-prompt)
  127.      (if ild-backtrace-string
  128.      (ild-debugger-command ild-backtrace-string)
  129.      (beep))
  130.      (if arg (backward-word arg) (backward-word 1))))
  131.  
  132. (defun ild-locals (&optional arg)
  133.  (interactive "P")
  134.  (if ild-locals-string
  135.      (ild-debugger-command ild-locals-string)
  136.      (beep)))
  137.  
  138. (defun ild-local (&optional arg)
  139.  (interactive "P")
  140.  (if arg
  141.      (if ild-local-string-arg
  142.      (ild-debugger-command (format ild-local-string-arg arg))
  143.      (beep))
  144.      (if ild-locals-string
  145.      (ild-debugger-command ild-locals-string)
  146.      (beep))))
  147.  
  148. (defun ild-return ()
  149.  (interactive)
  150.  (if ild-return-string
  151.      (ild-debugger-command ild-return-string)
  152.      (beep)))
  153.  
  154. (defun ild-retry ()
  155.  (interactive)
  156.  (if ild-retry-string
  157.      (ild-debugger-command ild-retry-string)
  158.      (beep)))
  159.  
  160. (defun ild-trap-on-exit (&optional arg)
  161.  (interactive "P")
  162.  (if ild-trap-on-exit-string
  163.      (ild-debugger-command ild-trap-on-exit-string)
  164.      (beep)))
  165.  
  166. (defun fast-lisp ()
  167.  "Use the production compiler."
  168.  (interactive)
  169.  (ilisp-send "(progn (proclaim '(optimize (speed 3) (safety 0) (space 0) (compilation-speed 0) (debug 0))) #+akcl (use-fast-links t))"))
  170.  
  171. (defun slow-lisp ()
  172.  "Use the development compiler."
  173.  (interactive)
  174.  (ilisp-send "(progn (proclaim '(optimize (speed 0) (safety 3) (space 3) (compilation-speed 3) (debug 3))) #+akcl (use-fast-links nil))"))
  175.  
  176. (defun select-lisp ()
  177.  "Select the lisp buffer in one window mode"
  178.  (interactive)
  179.  (cond ((and (lisp-mem ilisp-buffer
  180.                (buffer-list)
  181.                (function (lambda (x y) (equal x (buffer-name y)))))
  182.          (get-buffer-process (get-buffer ilisp-buffer)))
  183.     (delete-other-windows)
  184.     (switch-to-buffer ilisp-buffer))
  185.        (t (lucid)            ;put your favorite Lisp here
  186.       (delete-other-windows))))
  187.  
  188. (defun select-ilisp (arg)
  189.  "Select the current ILISP buffer."
  190.  (interactive "P")
  191.  (if (and (not arg)
  192.           (lisp-mem
  193.        (buffer-name (current-buffer))
  194.        ilisp-buffers
  195.        (function (lambda (x y) (equal x (format "*%s*" (car y)))))))
  196.      (setq ilisp-buffer (buffer-name (current-buffer)))
  197.      (let ((new (completing-read
  198.          (if ilisp-buffer
  199.              (format "Buffer [%s]: "
  200.                  (substring ilisp-buffer 1
  201.                     (1- (length ilisp-buffer))))
  202.              "Buffer: ")
  203.          ilisp-buffers nil t)))
  204.       (if (not (zerop (length new)))
  205.       (setq ilisp-buffer (format "*%s*" new))))))
  206.  
  207. ;;; This fixes a bug in ILISP 4.1
  208.  
  209. (defun defkey-ilisp (key command &optional inferior-only)
  210.  "Define KEY as COMMAND in ilisp-mode-map and lisp-mode-map unless
  211. optional INFERIOR-ONLY is T.  If the maps do not exist they will be
  212. created.  This should only be called after ilisp-prefix is set to the
  213. desired prefix."
  214.  (if (not ilisp-mode-map) (ilisp-bindings))
  215.  (define-key ilisp-mode-map key command)
  216.  (if (not inferior-only) (define-key lisp-mode-map key command)))
  217.  
  218. ;;; This is a convenient command since c-Z c-W doesn't default to the whole
  219. ;;; buffer if there is no region
  220.  
  221. (defun compile-buffer ()
  222.  "Compile the current buffer"
  223.  (interactive)
  224.  (compile-region-and-go-lisp (point-min) (point-max)))
  225.  
  226. (defkey-ilisp "\M-a"    'ild-abort t)
  227. (defkey-ilisp "\M-c"    'ild-continue t)
  228. (defkey-ilisp "\C-\M-n" 'ild-next t)
  229. (defkey-ilisp "\C-\M-p" 'ild-previous t)
  230. (defkey-ilisp "\C-c<"   'ild-top t)
  231. (defkey-ilisp "\C-c>"   'ild-bottom t)
  232. (defkey-ilisp "\M-b"    'ild-backtrace t)
  233. (defkey-ilisp "\C-\M-d" 'ild-locals t)
  234. (defkey-ilisp "\C-\M-l" 'ild-local t)
  235. (defkey-ilisp "\C-cr"   'ild-return t)
  236. (defkey-ilisp "\C-\M-r" 'ild-retry t)
  237. (defkey-ilisp "\C-xt"   'ild-trap-on-exit t)
  238. (define-key   global-map     "\C-cL" 'select-lisp)
  239. (ilisp-defkey lisp-mode-map  "\C-f"  'fast-lisp)
  240. (ilisp-defkey ilisp-mode-map "\C-f"  'fast-lisp)
  241. (ilisp-defkey lisp-mode-map  "\C-s"  'slow-lisp)
  242. (ilisp-defkey ilisp-mode-map "\C-s"  'slow-lisp)
  243.  
  244. (defdialect clisp "Common LISP" ilisp
  245.  (setq ilisp-load-or-send-command
  246.        "(or (and (load \"%s\" :if-does-not-exist nil) t)
  247.              (and (load \"%s\" :if-does-not-exist nil) t))")
  248.  (ilisp-load-init 'clisp "clisp")
  249.  (setq ilisp-package-regexp "^[ \t]*(in-package[ \t\n]*"
  250.        ilisp-package-command "(let ((*package* *package*)) %s (package-name *package*))"
  251.        ilisp-package-name-command "(package-name *package*)"
  252.        ilisp-in-package-command "(in-package \"%s\")"
  253.        ilisp-last-command "*"
  254.        ilisp-save-command "(progn (ILISP:ilisp-save) %s\n)"
  255.        ilisp-restore-command "(ILISP:ilisp-restore)"
  256.        ilisp-block-command "(progn %s\n)"
  257.        ilisp-eval-command "(ILISP:ilisp-eval \"%s\" \"%s\" \"%s\")"
  258.        ilisp-defvar-regexp "(defvar[ \t\n]")
  259.  (setq ilisp-defvar-command
  260.        "(ILISP:ilisp-eval \"(let ((form '%s)) (progn (makunbound (second form)) (eval form)))\" \"%s\" \"%s\")")
  261.  (setq ilisp-compile-command "(ILISP:ilisp-compile \"%s\" \"%s\" \"%s\")"
  262.        ilisp-describe-command "(ILISP:ilisp-describe \"%s\" \"%s\")"
  263.        ilisp-inspect-command "(ILISP:ilisp-inspect \"%s\" \"%s\")"
  264.        ilisp-arglist-command "(ILISP:ilisp-arglist \"%s\" \"%s\")")
  265.  (setq ilisp-documentation-types
  266.        '(("function") ("variable")
  267.      ("structure") ("type")
  268.      ("setf") ("class")
  269.      ("(qualifiers* (class ...))")))
  270.  (setq ilisp-documentation-command
  271.        "(ILISP:ilisp-documentation \"%s\" \"%s\" \"%s\")")
  272.  (setq ilisp-macroexpand-1-command
  273.        "(ILISP:ilisp-macroexpand-1 \"%s\" \"%s\")")
  274.  (setq ilisp-macroexpand-command "(ILISP:ilisp-macroexpand \"%s\" \"%s\")")
  275.  (setq ilisp-complete-command
  276.        "(ILISP:ilisp-matching-symbols \"%s\" \"%s\" %s %s %s)")
  277.  (setq ilisp-locator 'lisp-locate-clisp)
  278.  (setq ilisp-source-types
  279.        '(("function") ("macro") ("variable")
  280.      ("structure") ("type")
  281.      ("setf") ("class")
  282.      ("(qualifiers* (class ...))")))
  283.  (setq ilisp-callers-command "(ILISP:ilisp-callers \"%s\" \"%s\")"
  284.        ilisp-trace-command "(ILISP:ilisp-trace \"%s\" \"%s\" \"%s\")"
  285.        ilisp-untrace-command "(ILISP:ilisp-untrace \"%s\" \"%s\")")
  286.  (setq ilisp-directory-command "(namestring *default-pathname-defaults*)"
  287.        ilisp-set-directory-command
  288.        "(setq *default-pathname-defaults* (parse-namestring \"%s\"))")
  289.  (setq ilisp-load-command "(load \"%s\")")
  290.  (setq ilisp-compile-file-command
  291.        "(ILISP:ilisp-compile-file \"%s\" \"%s\")"))
  292.  
  293. (defdialect lucid "Lucid Common LISP" clisp
  294.  (ilisp-load-init 'lucid "lucid")
  295.  (setq comint-prompt-regexp "^\\(->\\)+ \\|^[^> ]*> "
  296.        comint-fix-error ":a"
  297.        ilisp-reset ":a :t"
  298.        comint-continue ":c"
  299.        comint-interrupt-regexp ">>Break: Keyboard interrupt"
  300.        comint-prompt-status
  301.        (function (lambda (old line)
  302.           (comint-prompt-status old line 'lucid-check-prompt))))
  303.  (setq ilisp-error-regexp "ILISP:[^\"]*\\|>>[^\n]*")
  304.  (setq ilisp-source-types (append ilisp-source-types '(("any"))))
  305.  (setq ilisp-find-source-command
  306.        "(ILISP:ilisp-source-files \"%s\" \"%s\" \"%s\")")
  307.  (setq ilisp-binary-command
  308.        "(first (last lucid::*load-binary-pathname-types*))")
  309.  (setq ild-abort-string ":A"
  310.        ild-continue-string ":C"
  311.        ild-next-string ":N"
  312.        ild-next-string-arg ":N %s"
  313.        ild-previous-string ":P"
  314.        ild-previous-string-arg ":P %s"
  315.        ild-top-string ":<"
  316.        ild-bottom-string ":>"
  317.        ild-backtrace-string ":B"
  318.        ild-locals-string ":V"
  319.        ild-local-string-arg ":L %s"
  320.        ild-return-string ":R"
  321.        ild-retry-string ":F"
  322.        ild-trap-on-exit-string ":X T"))
  323. (setq lucid-program "lisp")
  324.  
  325. (defdialect allegro "Allegro Common LISP" clisp
  326.  (ilisp-load-init 'allegro "allegro")
  327.  (setq comint-fix-error ":pop"
  328.        ilisp-reset ":reset"
  329.        comint-continue ":cont"
  330.        comint-interrupt-regexp  "Error: [^\n]* interrupt\)")
  331.  (setq comint-prompt-status
  332.        (function (lambda (old line)
  333.           (comint-prompt-status old line 'allegro-check-prompt))))
  334.  ;; <cl> or package> at top-level
  335.  ;; [0-9c] <cl> or package> in error
  336.  ;; (setq comint-prompt-regexp "^\\(\\[[0-9]*c*\\] \\|\\)\\(<\\|\\)[^>]*> ")
  337.  (setq comint-prompt-regexp "^\\(\\[[0-9]+i?c?\\] \\|\\[step\\] \\)?\\(<?[-A-Za-z]* ?[0-9]*?>\\|[-A-Za-z0-9]+([0-9]+):\\) ")
  338.  (setq ilisp-error-regexp
  339.        "\\(ILISP:[^\"]*\\)\\|\\(Error:[^\n]*\\)\\|\\(Break:[^\n]*\\)")
  340.  
  341.  (setq ilisp-binary-command "excl:*fasl-default-type*")
  342.  (setq ilisp-source-types (append ilisp-source-types '(("any"))))
  343.  (setq ilisp-find-source-command
  344.        "(ILISP:ilisp-source-files \"%s\" \"%s\" \"%s\")")
  345.  (setq ilisp-init-binary-command
  346.        "(let ((ext (or #+m68k \"68fasl\"
  347.                 #+sparc \"sfasl\"
  348.                 #+iris4d \"ifasl\"
  349.                         #+dec3100 \"pfasl\"
  350.                         excl:*fasl-default-type*)))
  351.            #+allegro-v4.0 (setq ext (concatenate 'string ext \"4\"))
  352.            ext)")
  353.  (setq ild-abort-string ":pop"
  354.        ild-continue-string ":cont"
  355.        ild-next-string ":dn"
  356.        ild-next-string-arg ":dn %s"
  357.        ild-previous-string ":up"
  358.        ild-previous-string-arg ":up %s"
  359.        ild-top-string ":to"
  360.        ild-bottom-string ":bo"
  361.        ild-backtrace-string ":bt"
  362.        ild-locals-string ":local"
  363.        ild-local-string-arg ":local %s"
  364.        ild-return-string nil        ;needs work
  365.        ild-retry-string ":rest"
  366.        ild-trap-on-exit-string ":boe"))
  367. (setq allegro-program "cl")
  368.  
  369. (defdialect akcl "Austin Kyoto Common LISP" kcl
  370.  (setq comint-prompt-regexp "^[-A-Z]*>+")
  371.  (setq ild-abort-string ":q"
  372.        ild-continue-string ":r"
  373.        ild-next-string ":up"
  374.        ild-next-string-arg ":up %s"
  375.        ild-previous-string ":down"
  376.        ild-previous-string-arg ":down %s"
  377.        ild-top-string ":down 1000000"
  378.        ild-bottom-string ":up 1000000"
  379.        ild-backtrace-string ":bt"
  380.        ild-locals-string ":fr"
  381.        ild-local-string-arg ":loc %s"
  382.        ild-return-string ":r"
  383.        ild-retry-string nil        ;needs work
  384.        ild-trap-on-exit-string nil))    ;needs work
  385. (setq akcl-program "akcl")
  386.  
  387. (defdialect cmulisp "CMU Common LISP" clisp
  388.  (ilisp-load-init 'cmu "cmulisp")
  389.  (if cmulisp-local-source-directory
  390.      (setq ilisp-source-directory-fixup-alist
  391.        (list
  392.         (cons cmulisp-source-directory-regexp
  393.           cmulisp-local-source-directory)))
  394.      (message "cmulisp-local-source-directory not set."))
  395.  (setq comint-prompt-regexp "^\\([0-9]+\\]+\\|\\*\\) "
  396.        ilisp-trace-command "(ILISP:cmulisp-trace \"%s\" \"%s\" \"%s\")"
  397.        comint-prompt-status
  398.        (function (lambda (old line)
  399.           (comint-prompt-status old line 'cmulisp-check-prompt)))
  400.        ilisp-error-regexp "ILISP:[^\"]*\\|Error [^\n]*"
  401.        ilisp-arglist-command "(ILISP:arglist \"%s\" \"%s\")"
  402.        ilisp-find-source-command "(ILISP:source-file \"%s\" \"%s\" \"%s\")"
  403.        comint-fix-error ":pop"
  404.        comint-continue ":go"
  405.        ilisp-reset ":q"
  406.        comint-interrupt-regexp "Interrupted at"
  407.        ilisp-binary-extension "sparcf")
  408.  (setq ild-abort-string ":abort"
  409.        ild-continue-string ":go"
  410.        ild-next-string ":down"
  411.        ild-next-string-arg nil        ;needs work
  412.        ild-previous-string ":up"
  413.        ild-previous-string-arg nil    ;needs work
  414.        ild-top-string ":bottom"
  415.        ild-bottom-string ":top"
  416.        ild-backtrace-string ":backtrace"
  417.        ild-locals-string ":l"
  418.        ild-local-string-arg "(debug:arg %s)"
  419.        ild-return-string nil        ;needs work (debug:debug-return x)
  420.        ild-retry-string nil        ;needs work
  421.        ild-trap-on-exit-string nil))    ;needs work
  422. (setq cmulisp-program "cmucl")
  423.  
  424.  
  425.